<?php
class Fotopreview extends AppModel {

	var $name = 'Fotopreview';

	//The Associations below have been created with all possible keys, those that are not needed can be removed
	var $belongsTo = array(
/*
			'User' => array('className' => 'User',
								'foreignKey' => 'user_id',
								'conditions' => '',
								'fields' => '',
								'order' => ''
			),
*/
			'Foto' => array('className' => 'Foto',
								'foreignKey' => 'foto_id',
								'conditions' => '',
								'fields' => array('id', 'alt'),
								'order' => ''
			)
	);
/*
	var $hasOne = array(
			'Foto' => array('className' => 'Foto',
								'foreignKey' => 'foto_id',
								'dependent' => false,
								'conditions' => '',
								'fields' => 'id',
								'order' => ''
			)
	);
*/

	function getFoto($hash) {
		$fields = array('type', 'name', 'content');
		$conditions = array('Fotopreview.hash'=>$hash);
		if ($hash) {
			return $this->find('first', array('conditions'=>$conditions, 'fields'=>$fields, 'recursive'=>-1));
		}

	}

	function getFotos($uid) {
		$conditions = array('Fotopreview.user_id'=>$uid);
		$fields = array('form', 'alt', 'hash');
		#'recursive'=>-1
		return $this->find('list', array('conditions'=>$conditions , 'fields'=>$fields));
	}

	function getMaxSize() {
		return 235;
	}

}
?>
